package com.aqie.easy.string;

/**
 * 709. 转换成小写字母
 * a - z : 97 - 122
 * A - Z : 65 - 90
 */
public class ToLowerCase {
    public static String toLowerCase(String str) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < str.length(); i++){
            char c = toLowercase(str.charAt(i));
            builder.append(c);
        }
        return builder.toString();
    }

    private static char toLowercase(char t) {
        if (t >= 'A' && t <= 'Z'){
            t = (char)(t + 32);
        }
        return t;
    }

    public static void main(String[] args) {
        int a = (int) 'a';
        int A = (int) 'A';
        int z = (int) 'z';
        int Z = (int) 'Z';
        System.out.println(a + " " + z + " " + A + " " + Z + " ");
        String str = "HEllo World";
        System.out.println(toLowerCase(str));
        System.out.println(str.toLowerCase());
    }
}
